package com.weakteam.orderonline.adminconsole.gwt.client.widget;


import com.google.gwt.user.client.ui.Label;
import com.weakteam.orderonline.adminconsole.gwt.client.domain.Category;


/**
 * Created by Max on 30.03.2014.
 */
public class MenuItemBox extends Label {

    private Category category;

    private boolean selected;

    public MenuItemBox(Category category) {
        this.category = category;
        this.selected = false;
        this.setStyleName("menu-item");
        this.setEnabled(category.getEnabled());
        this.setText(category.getName());
    }

    public boolean isSelected() {
        return selected;
    }
    public Category getCategory(){
        return this.category;
    }
    public int getMenuId() {
        return this.category.getId();
    }
    public void setMenuOrder (int index) {
        this.category.setOrder(index);
    }

    public void setSelected(boolean active) {
        this.selected = active;
        if (active) {
            this.addStyleName("menu-item-selected");
        } else {
            this.removeStyleName("menu-item-selected");
        }
    }

    public void setEnabled(Boolean enabled) {
        if (enabled) {
            this.removeStyleName("menu-item-disabled");
        } else {
            this.addStyleName("menu-item-disabled");
        }
    }


}